package com.ruoyi.ax.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ax.domain.AxBankCard;
import com.ruoyi.ax.service.IAxBankCardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 银行卡管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/ax/axBankCard")
public class AxBankCardController extends BaseController
{
    @Autowired
    private IAxBankCardService axBankCardService;

    /**
     * 查询银行卡管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AxBankCard axBankCard)
    {
        startPage();
        List<AxBankCard> list = axBankCardService.selectAxBankCardList(axBankCard);
        return getDataTable(list);
    }


    /**
     * 查询银行卡管理列表
     */
    @GetMapping("/mybanklist")
    public TableDataInfo mybanklist(AxBankCard axBankCard)
    {
        startPage();
        axBankCard.setSysUserId(SecurityUtils.getUserId()+"");
        List<AxBankCard> list = axBankCardService.selectAxBankCardList(axBankCard);
        return getDataTable(list);
    }


    /**
     * 导出银行卡管理列表
     */
    @Log(title = "银行卡管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AxBankCard axBankCard)
    {
        List<AxBankCard> list = axBankCardService.selectAxBankCardList(axBankCard);
        ExcelUtil<AxBankCard> util = new ExcelUtil<AxBankCard>(AxBankCard.class);
        util.exportExcel(response, list, "银行卡管理数据");
    }

    /**
     * 获取银行卡管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(axBankCardService.selectAxBankCardById(id));
    }

    /**
     * 新增银行卡管理
     */
    @Log(title = "银行卡管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AxBankCard axBankCard)
    {
        return toAjax(axBankCardService.insertAxBankCard(axBankCard));
    }

    @Log(title = "新增我的银行卡", businessType = BusinessType.INSERT)
    @PostMapping("/addMyBankCard")
    public AjaxResult addMyBankCard(@RequestBody AxBankCard axBankCard)
    {
        axBankCard.setSysUserId(SecurityUtils.getUserId()+"");
        return toAjax(axBankCardService.insertAxBankCard(axBankCard));
    }

    /**
     * 修改银行卡管理
     */
    @Log(title = "银行卡管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AxBankCard axBankCard)
    {
        return toAjax(axBankCardService.updateAxBankCard(axBankCard));
    }

    /**
     * 删除银行卡管理
     */
    @Log(title = "银行卡管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(axBankCardService.deleteAxBankCardByIds(ids));
    }
}
